package com.imooc.demo.converter;

import com.imooc.demo.dataobject.OrderMaster;
import com.imooc.demo.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Auther: 杨通通
 * @Date: 2021/11/6 22:31
 * @Description:
 */
public class OrderMaster2OrderDTOConverter {

    public static OrderDTO convert(OrderMaster orderMaster){
        OrderDTO orderDTO = new OrderDTO();
        BeanUtils.copyProperties(orderMaster,orderDTO);
        return orderDTO;
    }

    public static List<OrderDTO> convert(List<OrderMaster> list){
        return list.stream().map(e->
                    convert(e)
        ).collect(Collectors.toList());
    }
}